package com.example.mamsinject

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.util.Log
import android.view.View

class MainActivity2 : AppCompatActivity() {

    private val mHandler = Handler(
        Looper.getMainLooper()!!
    ) {
        when (it.what) {
            1 -> {
                Log.d("test", "deal 1")
                Thread.sleep(3000)
                Log.d("test", "deal 1 finish")
            }

            2 -> {
                Log.d("test", "deal 2")
                Thread.sleep(3000)
                Log.d("test", "deal 2 finish")
            }
        }
        true
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)
    }

    fun test1(view: View) {
        mHandler.sendEmptyMessage(1)
    }

    fun test2(view: View) {
        mHandler.sendEmptyMessage(2)
    }
}